
package com.feib.soeasy.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import net.sourceforge.stripes.util.Log;

import org.springframework.web.context.ContextLoaderListener;

/**
 * @title (#)StartupListener.java<br>
 * @description <br>
 * @author Jimmy Liu<br>
 * @version 1.0.0 2010/11/25
 * @copyright Far Eastern International Bank Copyright (c) 2010<br>
 * @20101025 create by Jimmy Liu<br>
 */
public class StartupListener extends ContextLoaderListener implements ServletContextListener {

    protected static final Log log = Log.getInstance(StartupListener.class);

    @Override
    public void contextInitialized(ServletContextEvent event) {
        // call Spring's context ContextLoaderListener to initialize
        // all the context files specified in web.xml
        super.contextInitialized(event);

//        ServletContext context = event.getServletContext();
//
//        setupContext(context);
    }

//    protected void setupContext(ServletContext ctx) {
//        ApplicationContext springCtx = WebApplicationContextUtils.getWebApplicationContext(ctx);
//        schemaexport(springCtx);
//    }

//    private static void schemaexport(ApplicationContext ctx) {
//        // String[] beanNames =
//        // ctx.getBeanNamesForType(AnnotationSessionFactoryBean.class);
//        log.debug("產生DB Schema");
//        log.debug("===========================================================");
//        AnnotationSessionFactoryBean factoryBean = (AnnotationSessionFactoryBean) ctx.getBean("&sessionFactory");
//        Configuration config = factoryBean.getConfiguration();
//        SchemaExport schemaExport = new SchemaExport(config);
//        schemaExport.setDelimiter(";");
//        schemaExport.setOutputFile("c:/ecommerce_db_schema.sql");
//        schemaExport.create(true, false);
//        log.debug("===========================================================");
//    }

}
